﻿//------------------------------------------------------------------------------
// System Name:    Customer Service Platform
// Component:      CIS Domestic ProvinceManagement
// Created By:     Samara Jiang (samaraj@wicresoft.com)
// Created Date:   2011-1-27
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASB.CC.Business.CIS;
using ASBCC.Business;
using ASBCC.Business.CIS;
using ASBCC.Database.EntityFramework;

namespace BEGDC.CC.Web.CIS2.Admin
{
    /// <summary>
    ///  CIS Domestic ProvinceManagement
    /// </summary>
    public partial class ProvinceManagement : EntityPage
    {

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override EntityDataSource EntitySource
        {
            get { return this.edsProvince; }
        }

        protected override TextBox EntitySearchTxt
        {
            get { return this.SearchText; }
        }

        protected override Button EntityAddBtn
        {
            get { return this.BtnAdd; }
        }

        protected override Button EntitySearchBtn
        {
            get { return this.Searchbtn; }
        }

        protected override Button EntityClearBtn
        {
            get { return this.Cleanbtn; }
        }

        protected override GridView EntityGrid
        {
            get { return this.gvProvince; }
        }

        protected override DetailsView EntityDetails
        {
            get { return this.dvProvince; }
        }

        protected override void OnEntityDisabling(int entityKey)
        {
            ProvinceManagementHelper.SetProvinceDisabled(entityKey);
            GlobalHelper.LogOperation(this.User.Identity.Name, SystemModule.CID, "Province disabled. id=" + entityKey + "; name=" + ProvinceManagementHelper.getName(entityKey));
        }

        protected override string GetEntityWhereExpression(string keyword)
        {
            return "(it.Name like N'%" + keyword + "%'"
                 + " or it.Description like N'%" + keyword + "%')";
        }

        protected override void OnEntityInserting(EntityDataSourceChangingEventArgs e)
        {
            var dc = e.Context;
            var province = e.Entity as Province;
            e.Cancel=true;
            ProvinceManagementHelper.OnProvinceInserting(province.Name,province.Description);
        }

        protected override void OnEntityUpdating(EntityDataSourceChangingEventArgs e)
        {

        }



        protected void edsProvince_Inserted(object sender, EntityDataSourceChangedEventArgs e)
        {
            var dc = e.Context;
            var province = e.Entity as Province;
            GlobalHelper.LogOperation(this.User.Identity.Name, SystemModule.CID, "Province inserted. id=" + province.ProvinceID + "; name=" + province.Name + "; Comment=" + province.Description);

        }

        protected void edsProvince_Updated(object sender, EntityDataSourceChangedEventArgs e)
        {
            var dc = e.Context;
            var province = e.Entity as Province;
            GlobalHelper.LogOperation(this.User.Identity.Name, SystemModule.CID, "Province updated. id=" + province.ProvinceID + "; name=" + province.Name + "; Comment=" + province.Description);
        }


    }
}
